package cn.tedu.account.service.impl;

import cn.tedu.account.mapper.AccountMapper;
import cn.tedu.account.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

@Service
@Slf4j

public class AccountImpl implements AccountService {
    @Autowired
    private AccountMapper accountM;
    
    @Transactional
    @Override
    public void decrease(Long userId, BigDecimal money) {
        accountM.decrease(userId,money);
        if(Math.random()<0.5){
            throw new RuntimeException("出现故障！");
        }
        log.info("执行减钱操作!");
    }
}
